﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Reflection;

using SBPweb.Forge.Contracts.Extensibility;

using SBPweb.Communication.Shared.Library;

namespace SBPweb.Communication.Client.Controls.Xmpp
{

    public class UserControlBase : UserControl
    {

        #region Private fields

        private MessengerBase messenger;

        #endregion

        #region Constructor logic

        public UserControlBase()
        {
        }

        #endregion

        #region Property accessors

        public virtual MessengerBase Messenger
        {
            get
            {
                if (messenger != null)
                {
                    return messenger;
                }
                IExtendable extendable = Application.Current as IExtendable;
                if (extendable == null)
                {
                    return null;
                }
                messenger = extendable.Get<MessengerBase>("Messenger");
                //Type type = Application.Current.GetType();
                //PropertyInfo pI = type.GetProperty("Messenger");
                //messenger = pI.GetValue(Application.Current, new object[] { }) as MessengerBase;
                return messenger;
            }
        }

        #endregion

    }

}